fix(proxy): only create Router when models or search_tools exist#20661
Merged
ishaan-jaff merged 1 commit intomainfrom Feb 7, 2026
Merged
fix(proxy): only create Router when models or search_tools exist#20661ishaan-jaff merged 1 commit intomainfrom
ishaan-jaff merged 1 commit intomainfrom
Conversation
Previously, PR #19818 (via #20205) removed the model_list check entirely, causing Router to be created even with no models AND no search_tools. This fix adds back a conditional check that creates the Router only when: - There are models to route, OR - There are search_tools configured This preserves the PR #19818 goal (search-tools-only deployments) while avoiding unnecessary Router creation when there's nothing to route. Fixes test_add_and_delete_deployments[0-None]
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Contributor
Greptile OverviewGreptile SummaryThis PR correctly fixes a regression from PR #19818/#20205 where the Router was being created unconditionally, even when there were no models and no search_tools to route. The fix adds back the conditional check Changes:
Impact:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/proxy_server.py | Adds conditional check to only create Router when models or search_tools exist, preventing unnecessary Router creation |
Sequence Diagram
sequenceDiagram
participant Client as Client Request
participant PS as ProxyServer
participant PC as ProxyConfig
participant R as Router
participant DB as Database
Client->>PS: Add/Delete Deployments
PS->>PC: _update_llm_router(new_models)
PC->>DB: get_config()
DB-->>PC: config_data
PC->>PC: parse_search_tools(config_data)
PC->>PC: decrypt_model_list_from_db(models_list)
alt llm_router is None AND master_key exists
alt len(_model_list) > 0 OR search_tools exists
PC->>R: Create litellm.Router(model_list, search_tools)
R-->>PC: Router instance
Note over PC,R: ✅ Router created when models or search_tools present
else Neither models nor search_tools
Note over PC: ❌ Skip Router creation (Fix)
end
else llm_router already exists
PC->>R: Update search_tools if provided
PC->>PC: _delete_deployment(db_models)
PC->>PC: _add_deployment(db_models)
end
PC-->>PS: Router updated/skipped
PS-->>Client: Success
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
test_add_and_delete_deployments[0-None]by adding back a conditional check for Router creation.Problem
PR #19818 (merged via #20205) removed the
if len(_model_list) > 0check entirely, causing Router to be created even when there are no models AND no search_tools.Solution
Add back a conditional check that creates the Router only when:
len(_model_list) > 0), ORsearch_toolsis truthy)Behavior
This preserves the PR #19818 goal (search-tools-only deployments work) while avoiding unnecessary Router creation.
Testing
All 6 test cases pass locally: